﻿@page "/counter"
@layout Shared.Layout.Designer
@* @inject ICrudBase<FunctionPage> db *@
@* @attribute [StreamRendering] *@

@using System.Text.Json
@using System.Text.Encodings.Web
@using System.Text.Unicode
@using Shared.Designer
@using BootstrapBlazor.Components
@* @using Ufo.Auto.Client.Layout *@
<PageTitle>设计界面</PageTitle>

@app
@if (SysModule != null && SysModule.Name != null)
{
    @SysModule.Name
}
@if (FunctionPage!=null)
{
       @* <div class="dmain"> *@
    <FormDesigner FunctionPage="@FunctionPage" IsDesigner="MyProperty"></FormDesigner>
    @* </div> *@
}
@code {
    [CascadingParameter(Name = "router")]
    public Module? SysModule { get; set; }
    public bool IsShowBackdropOpen { get; set; }
   
    private int currentCount = 0;
    [CascadingParameter]
    public bool MyProperty { get; set; } = true;
    public ContainerDto? ContainerData { get; set; }
    /// <summary>
    /// 页面数据
    /// </summary>
    [Parameter]
    [NotNull]
    public FunctionPage? FunctionPage { get; set; }
    [CascadingParameter]
    public string app { get; set; }
    protected override async void OnInitialized()
    {
        base.OnInitialized();
        // var ss =await db.SelectAll();
        // FunctionPage = ss.Data[1];
        // // FunctionPage = ss;
        //  return;
        FunctionPage = new FunctionPage();

        //ContainerData = new ContainerDto() {  ContainerType= ContainerType.Base,Rows=new List<RowDto>() {  new RowDto(){ Row=new List<ComponentDto>() { } }} };
        FunctionPage.ContainerData = new ContainerDto()
            {
                //ContainerType = ContainerType.Base,
                Rows = new List<RowDto>() { new RowDto() }
            };
        return;
    }
    private void IncrementCount()
    {
        currentCount++;
        MyProperty = !MyProperty;
    }
    private void IncrementCount2()
    {
        JsonSerializerOptions op = new JsonSerializerOptions()
            {
                Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.CjkUnifiedIdeographs)
            };
        var json = System.Text.Json.JsonSerializer.Serialize(FunctionPage.ContainerData, op);
    }
    private async Task IncrementCount3()
    {
        System.Console.WriteLine("onclick");
    }
}
